<?php

@include_once("commonFunctions.php");
$dealer = new Dealer($_POST['dealerCode']);
$_SESSION['storeAbbrev'] = $_POST['storeAbbrev'];
$_SESSION['dealerCode'] = $_POST['dealerCode'];
$store = new Store($_POST['storeAbbrev']);
if ($dealer != null) {
    ini_set('session.gc_maxlifetime', 60 * 60);   // 1 hour session time out
    $query = 'INSERT INTO logins (`id`, `dealerCode`, `time`) VALUES (NULL,  \''
            . $dealer->dealerCode . '\', ' . '\'' . date("Y-m-d H:i:s") . '\');';
    mysql_query($query) or die("query failed in validatelogin.php");

    $_SESSION['dealer'] = serialize($dealer);
    $_SESSION['store'] = serialize($store);
    header('Location:main.php');
    die();
} else {
    //header('Location: index.php');
    die();
}
?>